package com.todo.common.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author zhangwenxiang
 * @date 2024/4/8 10:56
 * @description
 */
@Getter
@AllArgsConstructor
public enum ResultTypeEnum {
    SUCCESS(0, "SUCCESS", "成功"),
    FAILED(1, "FAILED", "失败"),
    ERROR(2, "ERROR", "异常"),
    UNKNOWN(3, "UNKNOWN", "未知"),
    ;

    private static Map<Integer, ResultTypeEnum> typeMap = Arrays
            .stream(ResultTypeEnum.values())
            .collect(Collectors.toMap(ResultTypeEnum::getType, item -> item, (v1, v2) -> v2));

    private int type;
    private String code;
    private String name;


    public static ResultTypeEnum getByType(Integer type) {
        return typeMap.get(type);
    }
}
